package zj.it.bhne.gridengineeringsurvey.activity;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

import zj.it.bhne.gridengineeringsurvey.BaseActivity;
import zj.it.bhne.gridengineeringsurvey.R;

/**
 * 关于朱江
 *嘿嘿
 *
 */
public class AboutActivity extends BaseActivity implements View.OnClickListener {


    private Context context;

    @SuppressLint("ResourceType")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_about);
        context = this;
        initView();
    }

    /**
     * 初始化页面以及点击事件
     */
    private void initView() {
        TextView txt_msgtip = findViewById(R.id.txt_msgtip);
        TextView txt_about = findViewById(R.id.txt_about1);
        txt_about.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setClass(AboutActivity.this, AboutUsActivity.class);
                startActivity(intent);
            }
        });
        TextView banben = findViewById(R.id.banben);

        banben.setText(getString(R.string.about_name));

        txt_msgtip.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setClass(AboutActivity.this, ShuomingActivity.class);
                startActivity(intent);
            }
        });
        TextView txt_yinsi = findViewById(R.id.txt_yinsi);
        txt_yinsi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                new AlertDialog.Builder(AboutActivity.this).setTitle("清除缓存")//设置对话框标题

                        .setMessage("是否清除缓存数据！")//设置显示的内容

                        .setPositiveButton("确定", new DialogInterface.OnClickListener() {//添加确定按钮


                            @Override

                            public void onClick(DialogInterface dialog, int which) {//确定按钮的响应事件

                                // TODO Auto-generated method stub

                                finish();

                            }

                        }).setNegativeButton("返回", new DialogInterface.OnClickListener() {//添加返回按钮


                    @Override

                    public void onClick(DialogInterface dialog, int which) {//响应事件

                        // TODO Auto-generated method stub

                        Log.i("alertdialog", " 请保存数据！");

                    }

                }).show();//在按键响应事件中显示此对话框
            }
        });
        ImageButton activity_ib_back = findViewById(R.id.activity_ib_back);
        activity_ib_back.setOnClickListener(this);
        TextView activity_tv_title = findViewById(R.id.activity_tv_title);
        activity_tv_title.setOnClickListener(this);
        TextView activity_tv_save = findViewById(R.id.activity_tv_save);
        activity_tv_save.setOnClickListener(this);
        activity_tv_save.setText("");
        activity_tv_title.setText(getString(R.string.title_guanyubz));
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        finish();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.activity_ib_back:
                //放入item_id来告知bottomActivity需要显示那个activity
                Intent intent = new Intent(context, BottomActivity.class);
                intent.putExtra("item_id", 3);
                startActivity(intent);
                finish();
                break;
        }
    }
}
